package code;

import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Arrays;

public class FileTransfer {
    public static void main(String[] args) throws IOException {



        ServerSocket serverSocket = new ServerSocket(8888);
        PrintWriter bufferedWriter = new PrintWriter(new FileWriter("E:\\1.txt"), true);
        Socket socket = serverSocket.accept();

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        PrintWriter returnResult = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
        String message = null;




        while ((message = bufferedReader.readLine()) != null) {
//            if ("having overed".equalsIgnoreCase(message)) break;
            bufferedWriter.println(message);
        }
        returnResult.println("I have received your file");


    }
}
